package com.dkm.ec.activity.repository.impl;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.ec.activity.domain.LimitBuyActivityConfig;
import com.dkm.ec.activity.persistence.dao.LimitBuyActivityConfigQueryDao;
import com.dkm.ec.activity.persistence.entity.LimitBuyActivityConfigPo;
import com.dkm.ec.activity.repository.LimitBuyActivityConfigRepository;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hhq
 * @create 2017/8/14
 */
@Repository
public class LimitBuyActivityConfigRepositoryImpl extends AbstractRepository<String, LimitBuyActivityConfigPo, LimitBuyActivityConfig> implements LimitBuyActivityConfigRepository {

    @Resource
    private LimitBuyActivityConfigQueryDao limitBuyActivityConfigQueryDao;

    @Override
    public LimitBuyActivityConfig newInstance() {
        LimitBuyActivityConfig config =  SpringHelper.getBean(LimitBuyActivityConfig.class);
        config.setData(new LimitBuyActivityConfigPo());
        return config;
    }

    @Override
    public LimitBuyActivityConfig newInstance(LimitBuyActivityConfigPo po) {
        LimitBuyActivityConfig config =  SpringHelper.getBean(LimitBuyActivityConfig.class);
        config.setData(po);
        return config;
    }

    @Override
    protected IQueryDao<String, LimitBuyActivityConfigPo> getQueryDao() {
        return limitBuyActivityConfigQueryDao;
    }

    @Override
    public List<LimitBuyActivityConfigPo> findTodayActivities() {
        return limitBuyActivityConfigQueryDao.findByKey("findTodayActivities", null);
    }

    @Override
    public LimitBuyActivityConfigPo get(String activityId) {
        return limitBuyActivityConfigQueryDao.get(activityId);
    }
}
